package com.fanshuai.springcloud.config;

import com.fanshuai.springcloud.service.UserService;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import javax.annotation.Resource;
import java.util.List;

@SpringBootApplication(
        scanBasePackages = {"com.fanshuai.springcloud"}
)
public class MainConfig extends WebMvcConfigurerAdapter {
    @Resource
    private ObjectMapper objectMapper;

    @Override
    public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
        super.configureMessageConverters(converters);
    }

    @Bean(name = "baseUserService")
    @ConditionalOnMissingBean(UserService.class)
    public UserService userService() {
        return new UserService();
    }
}
